// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.worldMap;

import zombie.characters.IsoPlayer;
import zombie.network.GameClient;
import zombie.network.ServerOptions;

public final class WorldMapRemotePlayer {
    private short changeCount = 0;
    private final short OnlineID;
    private String username = "???";
    private String forename = "???";
    private String surname = "???";
    private String accessLevel = "None";
    private float x;
    private float y;
    private boolean invisible = false;
    private boolean bHasFullData = false;

    public WorldMapRemotePlayer(short _short) {
        this.OnlineID = _short;
    }

    public void setPlayer(IsoPlayer isoPlayer) {
        boolean _boolean = false;
        if (!this.username.equals(isoPlayer.username)) {
            this.username = isoPlayer.username;
            _boolean = true;
        }

        if (!this.forename.equals(isoPlayer.getDescriptor().getForename())) {
            this.forename = isoPlayer.getDescriptor().getForename();
            _boolean = true;
        }

        if (!this.surname.equals(isoPlayer.getDescriptor().getSurname())) {
            this.surname = isoPlayer.getDescriptor().getSurname();
            _boolean = true;
        }

        if (!this.accessLevel.equals(isoPlayer.accessLevel)) {
            this.accessLevel = isoPlayer.accessLevel;
            _boolean = true;
        }

        this.x = isoPlayer.x;
        this.y = isoPlayer.y;
        if (this.invisible != isoPlayer.isInvisible()) {
            this.invisible = isoPlayer.isInvisible();
            _boolean = true;
        }

        if (_boolean) {
            this.changeCount++;
        }
    }

    public void setFullData(short _short, String string0, String string1, String string2, String string3, float float0, float float1, boolean _boolean) {
        this.changeCount = _short;
        this.username = string0;
        this.forename = string1;
        this.surname = string2;
        this.accessLevel = string3;
        this.x = float0;
        this.y = float1;
        this.invisible = _boolean;
        this.bHasFullData = true;
    }

    public void setPosition(float float0, float float1) {
        this.x = float0;
        this.y = float1;
    }

    public short getOnlineID() {
        return this.OnlineID;
    }

    public String getForename() {
        return this.forename;
    }

    public String getSurname() {
        return this.surname;
    }

    public float getX() {
        return this.x;
    }

    public float getY() {
        return this.y;
    }

    public short getChangeCount() {
        return this.changeCount;
    }

    public boolean isInvisible() {
        return this.invisible;
    }

    public boolean hasFullData() {
        return this.bHasFullData;
    }

    public String getUsername(Boolean _boolean) {
        String string = this.username;
        if (_boolean && GameClient.bClient && ServerOptions.instance.ShowFirstAndLastName.getValue() && this.isAccessLevel("None")) {
            string = this.forename + " " + this.surname;
            if (ServerOptions.instance.DisplayUserName.getValue()) {
                string = string + " (" + this.username + ")";
            }
        }

        return string;
    }

    public String getUsername() {
        return this.getUsername(false);
    }

    public String getAccessLevel() {
        String string = this.accessLevel;

        return switch (string) {
            case "admin" -> "Admin";
            case "moderator" -> "Moderator";
            case "overseer" -> "Overseer";
            case "gm" -> "GM";
            case "observer" -> "Observer";
            default -> "None";
        };
    }

    public boolean isAccessLevel(String string) {
        return this.getAccessLevel().equalsIgnoreCase(string);
    }
}
